From a6492ad4237922b14a88c0329bf901dc9390a7d6 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 21 Oct 2008 14:15:11 +0100 Subject: [PATCH] x86, shadow: shadow_page_info must be same size as page_info. Signed-off-by: Keir Fraser --- xen/arch/x86/mm/shadow/private.h | 63 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h index bc9e5176b5..d0d6501260 100644 --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -227,32 +227,40 @@ extern void shadow_audit_tables(struct vcpu *v); struct shadow_page_info { union { - /* When in use, guest page we're a shadow of */ - unsigned long backpointer; - /* When free, order of the freelist we're on */ - unsigned int order; - }; - union { - /* When in use, next shadow in this hash chain */ - struct shadow_page_info *next_shadow; - /* When free, TLB flush time when freed */ - u32 tlbflush_timestamp; - }; - struct { - unsigned int type:5; /* What kind of shadow is this? */ - unsigned int pinned:1; /* Is the shadow pinned? */ - unsigned int count:26; /* Reference count */ - u32 mbz; /* Must be zero: this is where the owner - * field lives in a non-shadow page */ - } __attribute__((packed)); - union { - /* For unused shadow pages, a list of pages of this order; - * for pinnable shadows, if pinned, a list of other pinned shadows - * (see sh_type_is_pinnable() below for the definition of - * "pinnable" shadow types). */ - struct list_head list; - /* For non-pinnable shadows, a higher entry that points at us */ - paddr_t up; + /* Ensures that shadow_page_info is same size as page_info. */ + struct page_info page_info; + + struct { + union { + /* When in use, guest page we're a shadow of */ + unsigned long backpointer; + /* When free, order of the freelist we're on */ + unsigned int order; + }; + union { + /* When in use, next shadow in this hash chain */ + struct shadow_page_info *next_shadow; + /* When free, TLB flush time when freed */ + u32 tlbflush_timestamp; + }; + struct { + unsigned int type:5; /* What kind of shadow is this? */ + unsigned int pinned:1; /* Is the shadow pinned? */ + unsigned int count:26; /* Reference count */ + u32 mbz; /* Must be zero: this is where the + * owner field lives in page_info */ + } __attribute__((packed)); + union { + /* For unused shadow pages, a list of pages of this order; for + * pinnable shadows, if pinned, a list of other pinned shadows + * (see sh_type_is_pinnable() below for the definition of + * "pinnable" shadow types). */ + struct list_head list; + /* For non-pinnable shadows, a higher entry that points + * at us. */ + paddr_t up; + }; + }; }; }; @@ -261,7 +269,8 @@ struct shadow_page_info * Also, the mbz field must line up with the owner field of normal * pages, so they look properly like anonymous/xen pages. */ static inline void shadow_check_page_struct_offsets(void) { - BUILD_BUG_ON(sizeof (struct shadow_page_info) > sizeof (struct page_info)); + BUILD_BUG_ON(sizeof (struct shadow_page_info) != + sizeof (struct page_info)); BUILD_BUG_ON(offsetof(struct shadow_page_info, mbz) != offsetof(struct page_info, u.inuse._domain)); }; -- 2.30.2